<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
    <sk-staff-leave-form  ref="realForm" v-bind="$attrs" @modelLoading="getConfirmLoading" @ok="submitCallback" :disabled="disableSubmit" v-if="taskType == '教师请假'"></sk-staff-leave-form>
    <sk-visit-form ref="realForm" @modelLoading="getConfirmLoading" @ok="submitCallback" :disabled="disableSubmit"  v-if="taskType == '拜访'"></sk-visit-form>
    <sk-student-leave-form  ref="realForm" v-bind="$attrs" @modelLoading="getConfirmLoading" @ok="submitCallback" :disabled="disableSubmit" v-if="taskType == '儿童请假'"></sk-student-leave-form>
  </j-modal>
</template>

<script>

  import SkStaffLeaveForm from "./skStaffLeaveForm.vue";
  import SkVisitForm from "./SkVisitForm.vue";
  import skStudentLeaveForm from "./SkStudentLeaveForm.vue";
  export default {
    name: 'SkModal',
    components: {
      SkStaffLeaveForm,
      SkVisitForm,
      skStudentLeaveForm
    },
    data () {
      return {
        title:'',
        width:800,
        visible: false,
        disableSubmit: false,
        confirmLoading: false,
        taskType:"教师请假"
      }
    },
    computed:{
      
    },
    created(){
    },
    methods: {
      getConfirmLoading(data){
        this.confirmLoading = data;
      },
      add () {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.add();
        })
      },
      edit (record,approvlStatus) {
        this.visible=true
        this.taskType = record.taskType;
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record,approvlStatus);
        })
      },
      approval (record,approvlStatus) {
        this.visible=true
        this.taskType = record.taskType;
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record,approvlStatus);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.$refs.realForm.submitForm();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>